package norbert.utils {
	/* IMPORTS */
	
	import flash.display.DisplayObject;
	import flash.events.Event;
	
	import mx.core.Application;
	import mx.core.UIComponent;
	import mx.logging.*;
	import mx.managers.PopUpManager;
	
	public class PopUp extends EventHandler {
		/* PROPERTIES */
		
		private static var logger: ILogger = Log.getLogger("norbert.utils.PopUp");
		
		public var window: UIComponent;
		public var className: Class;
		public var modal: Boolean = false;
		public var parent: UIComponent;
		public var centerPopUp: Boolean = true;
		
		public var active: Boolean = true;

		/* METHODS */

		override protected function listener(event: Event): void {
			if (!active) return;

			if (!window) {
				window = new className();
			}
			
			window.owner = owner;
			
			PopUpManager.addPopUp(window, parent ? parent : DisplayObject(Application.application), modal);
			
			if (centerPopUp) {
				PopUpManager.centerPopUp(window);
			}
		}
	}
}
